package org.autumn.thread;

import java.util.concurrent.TimeUnit;

public class JoinMethod {

    private static int res = 0;

    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(() -> {
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            res = 10;
        }, "t1");

        t1.start();
        // 主线程需要等待t1线程结束后继续执行
        t1.join();
        System.out.println("res = " + res);

    }
}
